home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip
/
MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf
/
Programming
/
Disabling_OS
/
TakeSystem.s
/
TakeSystem.s
Wrap
Text File
|
1994-02-09
|
4KB
|
116 lines
*******************************************************************
* Short example of disabling of operating system for games, etc. *
* Disables system, changes the background colours a bit and then *
* enables system. *
* Uses system disabling method recommended by Toby Simpson in the *
* Amiga Answers column in Amiga Shopper Issue 18, October 1992. *
* Uses VPOS wait loop described by Jolyon Ralph in the Machine *
* Code column in Amiga Computing 1990. *
* Written by James Margitich, 20th of January 1993. *
*******************************************************************
SysBase equ 4
OPENLIB equ -552
CLOSELIB equ -414
Forbid equ -132
Permit equ -138
Exit equ -144
LoadView equ -222
WaitTOF equ -270
ActiView equ 34
VPOSR equ $dff004
COLOUR0 equ $dff180
move.l SysBase,a6 ;Put exec base address in a6
lea doslib_name,a1 ;Put pointer to name of dos in a1
moveq #0,d0 ;Any version will do
jsr OPENLIB(a6) ;Open dos library
move.l d0,DOSBase ;Save base address
lea gfxlib_name,a1 ;put pointer to name of gfx in a1
moveq #0,d0 ;Any version will do
jsr OPENLIB(a6) ;Open graphics library
move.l d0,GfxBase ;Save base address
cmp.l #0,GfxBase ;Was zero returned?
beq Error_No_Gfx ;If so, call error routine
jsr Forbid(a6) ;Disable multitasking
move.l GfxBase,a6 ;Put gfx base address in a6
move.l ActiView(a6),a1 ;Save pointer to system copper list
move.l a1,SysView
move.l #0,a1 ;Put NULL in a1
jsr LoadView(a6) ;Disable system copper list
jsr WaitTOF(a6) ;Wait for two vertical blanks
jsr WaitTOF(a6) ;To give system time to stop
;Here be the body of the program. Feel free to delete this, replace it
;with your own code and rename the file accordingly.
move.l #0,d0 ;Set loop counter to zero
move.l #0,d1 ;Set colour counter to zero
move.w #$3,d2 ;Set colour to $003
loop
move.w d2,COLOUR0 ;Set background colour
move.l VPOSR,d3 ;get beam position
and.l #%11111111100000000,d3 ;Only want vertical component
lsr.l #8,d3 ;Move it to lower byte
cmp.w #305,d3 ;Are we at the bottom of the screen?
bne.s loop ;If not, loop back now
cmp.l #250,d0 ;Is loop counter at 250 (50vbi)?
bne .samecolour
cmp.l #6,d1 ;Is colour counter 6?
beq .allfinished ;If so, finish up.
add.w #$002,d2 ;Increase colour no. by $002
move.l #0,d0 ;reset loop counter
add.l #1,d1 ;Increment colour counter
bra.s loop ;Just reset counter, remember?
.samecolour
add.l #1,d0 ;Increment loop counter
.fullframe
move.l VPOSR,d3 ;get beam position
and.l #%11111111100000000,d3 ;Only want vertical component
lsr.l #8,d3 ;Move it to lower byte
cmp.w #305,d3 ;Are we on next frame?
bge .fullframe ;If not, wait until we are
bra.s loop ;Loop back
.allfinished
;Here be where the main program ends.
move.l GfxBase,a6 ;Put gfx base address in a6
move.l SysView,a1 ;Put pointer to system view in a1
jsr LoadView(a6) ;Enable sytem
jsr WaitTOF(a6) ;Wait for two vertical blanks
jsr WaitTOF(a6) ;To let system get started
move.l SysBase,a6 ;Get ready to close libraries
jsr Permit(a6) ;Enable multitasking
move.l GfxBase,a1 ;Put gfx base address in a1
jsr CLOSELIB(a6) ;Close gfx library
move.l DOSBase,a1 ;Put dos base address in a1
jsr CLOSELIB(a6) ;close dos library
rts
Error_No_Gfx:
move.l DOSBase,a6 ;Get ready to use dos library
move.l #20,d1 ;returnCode set to 20
jsr Exit(a6) ;Exit the program
doslib_name:
dc.b "dos.library",0
gfxlib_name:
dc.b "graphics.library",0
even
DOSBase dc.l 0
GfxBase dc.l 0
SysView:
ds.l 1